Skip to content

refactor(todos): avoid redundant canonical source encoding and digests - #8372

Open
cocolord wants to merge 12 commits into
mainfrom
codex/small-kernel-transaction-20261108T1445
Open

cocolord wants to merge 12 commits into
mainfrom
codex/small-kernel-transaction-20261108T1445

Conversation

@cocolord

@cocolord cocolord commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Repeated canonical Todo reads re-encode already validated source bytes and hash unchanged scalar facts. This change reuses those bytes and proves unchanged scalars by exact equality inside the existing typed projection transaction. Complete-source clone/digest checks and source, revision, role, lease and replay fences remain intact; no cache, decoder or authority owner is added.

The existing M0 fixture reflects the merged status-module move with its 128→127 pin, measured baseline 520a1ab47, unchanged schema/allowlist and over-budget refusal. The report CLI integration test consumes the single work_contract through the existing controller and checks the owned next command, idle host and rejection of a changed command under its original source binding. Competing replan advice stays in the complete source.

The branch includes target main 3b16b8491, retaining the original proposal ancestry. Current runtime qualification is at 9baeafd8ab31639bf3794bbf0e1d4ccbb5716c7e; author head 15c9378211cb03f04fc0d85179bee90c62c5777d only appends paired RFC evidence, with identical runtime sources.

Validation Result and boundary
Complete CLI lifecycle Four complete 101-Todo source/wheel × File/default-SQLite cases pass at bb65769cc, then at the current native-context integration runtime with a newly rebuilt wheel. The two snapshots test different integration inputs, not a repeated frozen cost campaign.
Independent semantics and recovery Each case preserves the original synthetic fixture, independently verified sum-45 artifact, source/lease refusals, replay/recovery, four committed receipt kinds, one debit, completion time and two normal native exits.
Native-context callers 257 Python cases, seven progressive-context TypeScript cases and the control-plane typecheck pass on CPython 3.13.5/Node 22.22.3.
Package provenance All 1,962 inventoried present tracked wheel entries match the current runtime source. The two source-reuse owner files retain their earlier qualified hashes. No historical package-count benefit is inferred.
Earlier report qualification Source and isolated-wheel caller families each passed 71 cases at bb65769cc; dropping the real CLI next command makes the independent assertion fail.

Standard premerge at the author head passes six direct and nineteen selected checks with zero failures, warnings or advisories; committed bilingual and public-boundary checks pass. Change-quality policy is disabled and self-merge authority is false.

Earlier qualification remains attributed to its recorded heads: 82 Python and 105 TypeScript cases, real disposable PostgreSQL 16.15 store/service (391/11), and three packaged browser scenarios at 7e205166a. Exact-head PostgreSQL CI also passed at bb65769cc. Those runs do not qualify the new browser/installed-host or PostgreSQL host/wheel boundary.

Historical failures remain recorded: the retired report turn_envelope assertion failed identically on immutable 520a1ab47/aee777008; the earlier kernel-static failure used the stale 127/128 pin. Initial stale-bundle build refusal is retained separately from the rebuilt package. The Pages failure remains a separate hold; its stale-link file is outside this task's current write boundary.

Required new-head CI, independent exact-head review/readiness and explicit maintainer merge authorization remain pending. Whole-path/full marginal-cost/adoption, installed-host, PostgreSQL host/wheel, I3 for a minor release, full M1/R0/V10/R1, D2/D5/D6/D3 and context/model/split-install acceptance remain open. Frozen cost, attribution and normal-bytecode campaigns are not rerun or relabeled. #8374 remains an open component proposal pending reconciliation. This proposal does not complete the minimal kernel or upgrade an active host.

Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
cocolord and others added 2 commits November 9, 2026 00:58
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
@mergify

mergify Bot commented Nov 8, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @cocolord.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 8, 2026
cocolord and others added 4 commits November 9, 2026 01:14
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
…very

Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
@cocolord cocolord changed the title Avoid redundant digesting of unchanged canonical Todo scalars refactor(todos): avoid redundant canonical source encoding and digests Nov 8, 2026
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 8, 2026
cocolord and others added 3 commits November 9, 2026 01:58
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
loopx-agent
loopx-agent previously approved these changes Nov 8, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent, gpt-6.1-sol, OpenAI, runtime_reported, reasoning effort max

动机 / Motivation

在正式任务里打开 Todo 或继续受管 Turn 的操作者,会反复从权威存储读取任务和下一步。 一次读取需要处理用户与 Agent 两组任务字段。原版先各自保存 JSON 再重复编码校验。候选保留已经校验的完整字节,实测从四次字段编码降到两次。 在 File 和 SQLite 上,重排映射键仍能使用原来源。把布尔值改成整数、替换所有者、篡改计数或删掉字段仍会失去来源资格或被拒绝。 验证范围覆盖来源绑定、读回和恢复。完整端到端成本、安装宿主和收益归因留给独立资格验证。 这批证据确认一次读取少做了编码和摘要工作。长期延迟、跨宿主部署与整套运行成本仍需单独测量。

改动思路 / Approach

保持现有 TypeScript 权威读取和 Python 兼容传输的边界,复用已校验内容,决策和持久状态仍由原所有者处理。 本 PR 的新增生产改动限于完整字段编码复用与未改变的标量跳过重哈希,报告测试和模块 pin 分别修复已有验证断点。 现有读取先绑定当前存储修订、游标和完整字段摘要,再把结果交给 Todo、配额与 Turn 的既有消费方。过期或篡改后的读回进入原有拒绝和恢复路径。完整的来源校验有实际调用方,省掉的是重复的中间编码和相等标量摘要。

具体改动 / Changes

关键代码讲解

  • bind_canonical_todo_sources。先对完整字段验证摘要,成功后把同一份 UTF-8 字节留作以后比较的依据。摘要不匹配时仍走完整的调用方输入路径。 提交源码
  • canonical_todo_source_reference。在原请求里解码完整依据再比较。映射键顺序可以变化,列表顺序和布尔、整数等类型仍参与判断,受保护事实有变化就失去原来源。 提交源码
  • resolveCanonicalSource。只有完全相同的标量跳过摘要比较。对象、数组、被改动的标量和缺失键仍按原规则处理,不能替换由存储拥有的事实。 提交源码
  • test_calendar_actual_cli_preserves_capability_action_without_host。直接把完整工作合同交给控制器。在计划、预演和执行入口核对同一条报告命令、Host 保持空闲和未提前写入的效果。篡改命令后由原合同校验拒绝。 提交源码

报告旧断言读取已退役的载体。当前入口直接读完整工作合同,保留竞争建议并交由原控制器判断优先级。模块数量已经在合入的迁移里从 128 变为 127,本 PR 把仍固定为 128 的 pin 降到实测数,保留精确计数、入口允许列表和超额拒绝。 我按当前目标主干的 docs/architecture/rfcs/monorepo-distribution-split-v0.md 对照了全量差异,规范版本为 69ddc610846f98b8d9b6c5c374ac4aefdd2d4ed0。I2 的单一权威读取、I8 的完整和新鲜上下文、I9 的可复核测量范围都能对应到上述实现与验证。M0 的计数依据是已合入的移动,基线失败也已保留。 版本固定的规范

对主干的风险 / Risks

原生队列的旧基线比实际合入祖先早。整包审阅保留 23 个文件的范围,已有 #8275、#8373、#8375 的逻辑已进入 main,候选独有的是上述 8 个文件。 最危险的反例是将看似相等的值当成原事实。直接替换数字类型、删除字段、改写嵌套所有者和换用旧游标都应被拒绝。恢复原值后能继续从同一作用域读回,长任务的回归也验证原结算只发生一次。

PASS。候选的 18 项本地测试通过。相同范围在基线有 16 项通过,报告旧字段 KeyError 和 127/128 pin 两项失败。 隔离 PostgreSQL 16.15 的 authority-store 391 项与服务 11 项均通过,跳过 0 项。控制平面 TypeScript 类型检查通过。 精确 diff 检查和双语 RFC 检查均通过。反例在同一个真实入口运行。原提交拒绝错误数据,移除类型保护的变体才接受了它。

我的整体评价 / Verdict

没有阻塞评审的代码发现。原有任务继续执行与 CLI 使用路径得到保留,减少的编码次数已有可复核的 File 和 SQLite 对照。核对了 Todo 与报告的 CLI 数据和消费路径,当前改动属于来源绑定与验证,视觉评审范围为空。 宿主安装、浏览器和完整链路成本仍属独立验证范围。本次评审与合并就绪分别记录。

English verdict: APPROVE at bb65769. Exact-head File and SQLite checks preserved source provenance and replay, the corrected report caller and root-module pin passed, and isolated PostgreSQL 16.15 passed its store and service suites.

@cocolord
cocolord dismissed loopx-agent’s stale review November 8, 2026 19:14

The merge-base changed after approval.

cocolord and others added 2 commits November 9, 2026 03:16
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants